
import { userStore } from '@/pinia/modules/user'

export const Permission = (app:any) => {
  app.directive('rule', {
    mounted: function(el:any, binding:any) {
      const { roles } = userStore()
      const index = roles.findIndex(item => {
        return item == binding.value
      })
      if (binding.value && index == -1) {
        // 移除组件
        el.parentNode.removeChild(el)
      }
    },
  })
}
